package com.mfrs.adapter;

import java.util.List;


import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

import hk.cic.demointegrationapp.R;

public class LvRecordAdapter extends BaseAdapter {
	private List<RecordBean> datas;
	
	public LvRecordAdapter(List<RecordBean> datas){
		this.datas = datas;
	}
	
	@Override
	public int getCount() {
		return datas == null ? 0 : datas.size();
	}

	@Override
	public Object getItem(int position) {
		return null;
	}

	@Override
	public long getItemId(int position) {
		return 0;
	}

	@Override
	public View getView(int position, View v, ViewGroup parent) {
		VH vh = null;
		if(v == null){
			v = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_lv_record, parent, false);
			vh = new VH();
			vh.tv_date = (TextView)v.findViewById(R.id.tv_date);
			vh.tv_user = (TextView)v.findViewById(R.id.tv_user);
			vh.tv_out = (TextView)v.findViewById(R.id.tv_out);
			vh.tv_int = (TextView)v.findViewById(R.id.tv_int);
			v.setTag(vh);
		}else{
			vh = (VH)v.getTag();
		}
		vh.tv_date.setText(datas.get(position).getDate() + "");
		vh.tv_user.setText(datas.get(position).getUser() + "");
		vh.tv_out.setText(datas.get(position).getOutTime() + "");
		vh.tv_int.setText(datas.get(position).getInTime() + "");
		return v;
	}
	
	private static class VH{
		TextView tv_date, tv_user, tv_out, tv_int;
	}
}